<template>
  <div class="wrapper" v-show="visiable">
    <div class="mast" @click="$emit('closeMask')"></div>

    <div class="dialog" :style="{ width: width }">
      <div class="header">
        <slot name="header">{{ title }} </slot>

        <i class="zh-icon-close" @click="$emit('closeDialog', !visiable)">X</i>
      </div>
      <!-- 中间内容不确定-放插槽 -->
      <div class="content">
        <slot name="body">7757575757575</slot>
      </div>
      <!-- 底部内容不确定-放插槽 -->
      <div class="footer">
        <slot name="footer">尾部内容</slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    title: {
      type: String,
      default: "默认标题1",
    },
    visiable: {
      type: Boolean,
      default: false,
    },
    width: {
      type: String,
      default: "50%",
    },
  },

  setup({ emit }) {
    return {};
  },
};
</script>


<style lang="scss" scoped>
* {
  box-sizing: border-box;
}
.wrapper {
  .mast {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    background: #808080;
    opacity: 0.5;
    animation: mask 1s linear forwards;
  }

  .dialog {
    width: 50%;
    height: 300px;
    background: white;
    border: 1px solid black;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: dialog 1s linear forwards;

    .header {
      height: 50px;
      padding: 10px;
      font-size: 18px !important;
      border-bottom: 1px solid rgb(122, 122, 122);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
    .content {
      padding: 20px;
    }
    .footer {
      padding: 10px;
      height: 50px;
      width: 100%;
      display: flex;
      align-items: center;
      justify-content: flex-end;
      border-top: 1px solid rgb(122, 122, 122);
      position: absolute;
      bottom: 0;
    }
  }
}
@keyframes mask {
  from {
    opacity: 0;
  }
  to {
    opacity: 0.5;
  }
}
@keyframes dialog {
  from {
    top: 0;
  }
  to {
    top: 50%;
  }
}
</style>